Before sourcing file process.R, you need to download it at the folder in which you’ve saved the Rmd file. The R script is available at this link.
pkgs2use<- c('haven','tidyverse','here','DiagrammeR','interactions')
inst.load.pkg <- function(pkg){
if (!require(pkg, character.only = TRUE)) {
install.packages(pkg, dependencies = TRUE)
library(pkg, character.only = TRUE)
}
}
invisible(lapply(pkgs2use,inst.load.pkg))
rm(pkgs2use,inst.load.pkg)
source(here("Complementos","MedModR","MATERIALS","Practice","process.R"))
********************* PROCESS for R Version 4.1.1 *********************
Written by Andrew F. Hayes, Ph.D. www.afhayes.com
Documentation available in Hayes (2022). www.guilford.com/p/hayes3
***********************************************************************
PROCESS is now ready for use.
Copyright 2022 by Andrew F. Hayes ALL RIGHTS RESERVED
Workshop schedule at http://haskayne.ucalgary.ca/CCRAM
StressDF <- read_sav(here("Complementos","MedModR","MATERIALS","Practice","DataSets", "estress.sav"))
results <- process(StressDF,y='withdraw',x='estress',m='affect',total=1,model=4,progress=0,save=3)
********************* PROCESS for R Version 4.1.1 *********************
Written by Andrew F. Hayes, Ph.D. www.afhayes.com
Documentation available in Hayes (2022). www.guilford.com/p/hayes3
***********************************************************************
Model : 4
Y : withdraw
X : estress
M : affect
Sample size: 262
Random seed: 827757
***********************************************************************
Outcome Variable: affect
Model Summary:
R R-sq MSE F df1 df2 p
0.3401 0.1156 0.4650 33.9988 1.0000 260.0000 0.0000
Model:
coeff se t p LLCI ULCI
constant 0.7994 0.1433 5.5777 0.0000 0.5172 1.0816
estress 0.1729 0.0296 5.8308 0.0000 0.1145 0.2313
***********************************************************************
Outcome Variable: withdraw
Model Summary:
R R-sq MSE F df1 df2 p
0.4247 0.1804 1.2841 28.4946 2.0000 259.0000 0.0000
Model:
coeff se t p LLCI ULCI
constant 1.4471 0.2520 5.7420 0.0000 0.9508 1.9433
estress -0.0768 0.0524 -1.4667 0.1437 -0.1800 0.0263
affect 0.7691 0.1031 7.4627 0.0000 0.5662 0.9721
************************ TOTAL EFFECT MODEL ***************************
Outcome Variable: withdraw
Model Summary:
R R-sq MSE F df1 df2 p
0.0641 0.0041 1.5543 1.0718 1.0000 260.0000 0.3015
Model:
coeff se t p LLCI ULCI
constant 2.0619 0.2620 7.8691 0.0000 1.5459 2.5778
estress 0.0561 0.0542 1.0353 0.3015 -0.0506 0.1629
***********************************************************************
Bootstrapping in progress. Please wait.
************ TOTAL, DIRECT, AND INDIRECT EFFECTS OF X ON Y ************
Total effect of X on Y:
effect se t p LLCI ULCI
0.0561 0.0542 1.0353 0.3015 -0.0506 0.1629
Direct effect of X on Y:
effect se t p LLCI ULCI
-0.0768 0.0524 -1.4667 0.1437 -0.1800 0.0263
Indirect effect(s) of X on Y:
Effect BootSE BootLLCI BootULCI
affect 0.1330 0.0340 0.0709 0.2034
***********************************************************************
Map of column names to model coefficients in bootstrap matrix:
name Conseqnt Antecdnt
col1 affect constant
col2 affect estress
col3 withdraw constant
col4 withdraw estress
col5 withdraw affect
******************** ANALYSIS NOTES AND ERRORS ************************
Level of confidence for all confidence intervals in output: 95
Number of bootstraps for percentile bootstrap confidence intervals: 5000
resCOEFS <- round(results[[2]],2)
starlabs <- c(paste("c´=",resCOEFS[12,1],"<FONT POINT-SIZE='6'><SUP>",ifelse(resCOEFS[12,4]<.001,'***',ifelse(resCOEFS[12,4]<.01,'**',ifelse(resCOEFS[12,4]<.05,'*',' '))),"</SUP></FONT>",sep=''),
paste("a<FONT POINT-SIZE='6'><SUB>1</SUB></FONT>=",resCOEFS[3,1],"<FONT POINT-SIZE='6'><SUP>",ifelse(resCOEFS[3,4]<.001,'***',ifelse(resCOEFS[3,4]<.01,'**',ifelse(resCOEFS[3,4]<.05,'*',' '))),"</SUP></FONT>",sep=''),
paste("b<FONT POINT-SIZE='6'><SUB>1</SUB></FONT>=",resCOEFS[7,1],"<FONT POINT-SIZE='6'><SUP>",ifelse(resCOEFS[7,4]<.001,'***',ifelse(resCOEFS[7,4]<.01,'**',ifelse(resCOEFS[7,4]<.05,'*',' '))),"</SUP></FONT>",sep=''),
paste("a<FONT POINT-SIZE='6'><SUB>2</SUB></FONT>=",resCOEFS[6,1],"<FONT POINT-SIZE='6'><SUP>",ifelse(resCOEFS[6,4]<.001,'***',ifelse(resCOEFS[6,4]<.01,'**',ifelse(resCOEFS[6,4]<.05,'*',' '))),"</SUP></FONT>",sep='')
)
grViz(paste("
digraph SEM {
graph [layout = neato,
overlap = true,
outputorder = edgesfirst
title='TF']
node [shape = rectangle,fontsize=10]
a [pos = '-1,0!', label = 'STRESS']
b [pos = '1,1!', label = 'AFFECT']
c [pos = '3,0!', label = 'WITHDRAWAL']
node [shape=plaintext,fontsize=9.5]
ac [pos='1,.1!', label = <",starlabs[1],">]
ab [pos='-0.2,.6!', label = <",starlabs[2],">]
bc [pos='2.2,.6!', label = <",starlabs[3],">]
a->b
a->c
b->c
}
",sep='')
)
pmiDF <- read_sav(here("Complementos","MedModR","MATERIALS","Practice","DataSets", "pmi.sav"))
results <- process(pmiDF,y='reaction',x='cond',m=c('pmi','import'),total=1,model=4,save=3,progress=0)
********************* PROCESS for R Version 4.1.1 *********************
Written by Andrew F. Hayes, Ph.D. www.afhayes.com
Documentation available in Hayes (2022). www.guilford.com/p/hayes3
***********************************************************************
Model : 4
Y : reaction
X : cond
M1 : pmi
M2 : import
Sample size: 123
Random seed: 461623
***********************************************************************
Outcome Variable: pmi
Model Summary:
R R-sq MSE F df1 df2 p
0.1808 0.0327 1.7026 4.0878 1.0000 121.0000 0.0454
Model:
coeff se t p LLCI ULCI
constant 5.3769 0.1618 33.2222 0.0000 5.0565 5.6973
cond 0.4765 0.2357 2.0218 0.0454 0.0099 0.9431
***********************************************************************
Outcome Variable: import
Model Summary:
R R-sq MSE F df1 df2 p
0.1809 0.0327 2.9411 4.0942 1.0000 121.0000 0.0452
Model:
coeff se t p LLCI ULCI
constant 3.9077 0.2127 18.3704 0.0000 3.4866 4.3288
cond 0.6268 0.3098 2.0234 0.0452 0.0135 1.2401
***********************************************************************
Outcome Variable: reaction
Model Summary:
R R-sq MSE F df1 df2 p
0.5702 0.3251 1.6628 19.1118 3.0000 119.0000 0.0000
Model:
coeff se t p LLCI ULCI
constant -0.1498 0.5298 -0.2828 0.7778 -1.1989 0.8993
cond 0.1034 0.2391 0.4324 0.6662 -0.3701 0.5768
pmi 0.3965 0.0930 4.2645 0.0000 0.2124 0.5806
import 0.3244 0.0707 4.5857 0.0000 0.1843 0.4645
************************ TOTAL EFFECT MODEL ***************************
Outcome Variable: reaction
Model Summary:
R R-sq MSE F df1 df2 p
0.1603 0.0257 2.3610 3.1897 1.0000 121.0000 0.0766
Model:
coeff se t p LLCI ULCI
constant 3.2500 0.1906 17.0525 0.0000 2.8727 3.6273
cond 0.4957 0.2775 1.7860 0.0766 -0.0538 1.0452
***********************************************************************
Bootstrapping in progress. Please wait.
************ TOTAL, DIRECT, AND INDIRECT EFFECTS OF X ON Y ************
Total effect of X on Y:
effect se t p LLCI ULCI
0.4957 0.2775 1.7860 0.0766 -0.0538 1.0452
Direct effect of X on Y:
effect se t p LLCI ULCI
0.1034 0.2391 0.4324 0.6662 -0.3701 0.5768
Indirect effect(s) of X on Y:
Effect BootSE BootLLCI BootULCI
TOTAL 0.3923 0.1642 0.0925 0.7350
pmi 0.1890 0.1035 0.0063 0.4154
import 0.2033 0.1134 0.0072 0.4564
***********************************************************************
Map of column names to model coefficients in bootstrap matrix:
name Conseqnt Antecdnt
col1 pmi constant
col2 pmi cond
col3 import constant
col4 import cond
col5 reaction constant
col6 reaction cond
col7 reaction pmi
col8 reaction import
******************** ANALYSIS NOTES AND ERRORS ************************
Level of confidence for all confidence intervals in output: 95
Number of bootstraps for percentile bootstrap confidence intervals: 5000
resCOEFS <- round(results[[2]],2)
starlabs <- c(paste("c´=",resCOEFS[9,1],"<FONT POINT-SIZE='6'><SUP>",ifelse(resCOEFS[9,4]<.001,'***',ifelse(resCOEFS[9,4]<.01,'**',ifelse(resCOEFS[9,4]<=.05,'*',' '))),"</SUP></FONT>",sep=''),
paste("a<FONT POINT-SIZE='6'><SUB>1</SUB></FONT>=",resCOEFS[6,1],"<FONT POINT-SIZE='6'><SUP>",ifelse(resCOEFS[6,4]<.001,'***',ifelse(resCOEFS[6,4]<.01,'**',ifelse(resCOEFS[6,4]<=.05,'*',' '))),"</SUP></FONT>",sep=''),
paste("b<FONT POINT-SIZE='6'><SUB>1</SUB></FONT>=",resCOEFS[11,1],"<FONT POINT-SIZE='6'><SUP>",ifelse(resCOEFS[11,4]<.001,'***',ifelse(resCOEFS[11,4]<.01,'**',ifelse(resCOEFS[11,4]<=.05,'*',' '))),"</SUP></FONT>",sep=''),
paste("a<FONT POINT-SIZE='6'><SUB>2</SUB></FONT>=",resCOEFS[3,1],"<FONT POINT-SIZE='6'><SUP>",ifelse(resCOEFS[3,4]<.001,'***',ifelse(resCOEFS[3,4]<.01,'**',ifelse(resCOEFS[3,4]<=.05,'*',' '))),"</SUP></FONT>",sep=''),
paste("b<FONT POINT-SIZE='6'><SUB>2</SUB></FONT>=",resCOEFS[10,1],"<FONT POINT-SIZE='6'><SUP>",ifelse(resCOEFS[10,4]<.001,'***',ifelse(resCOEFS[10,4]<.01,'**',ifelse(resCOEFS[10,4]<=.05,'*',' '))),"</SUP></FONT>",sep='')
)
grViz(paste("
digraph SEM {
graph [layout = neato,
overlap = true,
outputorder = edgesfirst
title='TF']
node [shape = rectangle,fontsize=10]
a [pos = '-1,0!', label = 'CONDITION']
b [pos = '1,1!', label = 'IMPORT']
c [pos = '3,0!', label = 'REACTION']
d [pos = '1,-1!', label = 'PMI']
node [shape=plaintext,fontsize=9.5]
ac [pos='1,.1!', label = <",starlabs[1],">]
ab [pos='-0.2,.6!', label = <",starlabs[2],">]
bc [pos='2.2,.6!', label = <",starlabs[3],">]
ad [pos='0.3,-.4!', label = <",starlabs[4],">]
dc [pos='1.8,-.4!', label = <",starlabs[5],">]
a->b
a->c
b->c
a->d
d->c
}
",sep='')
)
disasterDF <- read_sav(here("Complementos","MedModR","MATERIALS","Practice","DataSets", "disaster.sav"))
process(disasterDF,x='frame',y='justify',w='skeptic',model=1,jn=1)
********************* PROCESS for R Version 4.1.1 *********************
Written by Andrew F. Hayes, Ph.D. www.afhayes.com
Documentation available in Hayes (2022). www.guilford.com/p/hayes3
***********************************************************************
Model : 1
Y : justify
X : frame
W : skeptic
Sample size: 211
***********************************************************************
Outcome Variable: justify
Model Summary:
R R-sq MSE F df1 df2 p
0.4962 0.2463 0.6609 22.5430 3.0000 207.0000 0.0000
Model:
coeff se t p LLCI ULCI
constant 2.4515 0.1490 16.4486 0.0000 2.1577 2.7454
frame -0.5625 0.2179 -2.5811 0.0105 -0.9921 -0.1328
skeptic 0.1051 0.0381 2.7559 0.0064 0.0299 0.1803
Int_1 0.2012 0.0553 3.6401 0.0003 0.0922 0.3101
Product terms key:
Int_1 : frame x skeptic
Test(s) of highest order unconditional interaction(s):
R2-chng F df1 df2 p
X*W 0.0482 13.2503 1.0000 207.0000 0.0003
----------
Focal predictor: frame (X)
Moderator: skeptic (W)
Conditional effects of the focal predictor at values of the moderator(s):
skeptic effect se t p LLCI ULCI
1.5920 -0.2422 0.1495 -1.6203 0.1067 -0.5369 0.0525
2.8000 0.0008 0.1166 0.0072 0.9942 -0.2290 0.2307
5.2000 0.4837 0.1505 3.2134 0.0015 0.1869 0.7804
Moderator value(s) defining Johnson-Neyman significance region(s):
Value % below % above
1.1713 6.6351 93.3649
3.9339 67.7725 32.2275
Conditional effect of focal predictor at values of the moderator:
skeptic effect se t p LLCI ULCI
1.0000 -0.3613 0.1729 -2.0900 0.0378 -0.7021 -0.0205
1.1713 -0.3268 0.1658 -1.9715 0.0500 -0.6536 0.0000
1.4211 -0.2766 0.1559 -1.7743 0.0775 -0.5839 0.0307
1.8421 -0.1919 0.1407 -1.3637 0.1742 -0.4693 0.0855
2.2632 -0.1072 0.1280 -0.8373 0.4034 -0.3595 0.1451
2.6842 -0.0225 0.1185 -0.1895 0.8499 -0.2561 0.2112
3.1053 0.0623 0.1131 0.5505 0.5826 -0.1607 0.2852
3.5263 0.1470 0.1123 1.3082 0.1923 -0.0745 0.3684
3.9339 0.2290 0.1161 1.9715 0.0500 0.0000 0.4579
3.9474 0.2317 0.1163 1.9914 0.0477 0.0023 0.4610
4.3684 0.3164 0.1246 2.5388 0.0119 0.0707 0.5621
4.7895 0.4011 0.1364 2.9401 0.0037 0.1321 0.6700
5.2105 0.4858 0.1509 3.2192 0.0015 0.1883 0.7833
5.6316 0.5705 0.1674 3.4083 0.0008 0.2405 0.9005
6.0526 0.6552 0.1853 3.5354 0.0005 0.2898 1.0206
6.4737 0.7399 0.2044 3.6208 0.0004 0.3370 1.1428
6.8947 0.8246 0.2242 3.6785 0.0003 0.3827 1.2666
7.3158 0.9093 0.2446 3.7176 0.0003 0.4271 1.3916
7.7368 0.9941 0.2655 3.7440 0.0002 0.4706 1.5175
8.1579 1.0788 0.2868 3.7617 0.0002 0.5134 1.6441
8.5789 1.1635 0.3083 3.7735 0.0002 0.5556 1.7713
9.0000 1.2482 0.3301 3.7810 0.0002 0.5974 1.8990
******************** ANALYSIS NOTES AND ERRORS ************************
Level of confidence for all confidence intervals in output: 95
W values in conditional tables are the 16th, 50th, and 84th percentiles.
mod.moderation <- lm(justify~frame*skeptic,data=disasterDF)
interactions::johnson_neyman(model = mod.moderation, pred = frame,modx = skeptic)
JOHNSON-NEYMAN INTERVAL
When skeptic is OUTSIDE the interval [1.17, 3.93], the slope of frame is p
< .05.
Note: The range of observed values of skeptic is [1.00, 9.00]